import request from "../axios";

import {requestHandle} from "../axios";

import {Toast} from 'antd-mobile';
import {R, API_PREFIX} from "@/assets/js/dict.js"
/*
* 订单相关的接口
* */

/*家长的接口*/

/**
 * 家长添加订单
 * @constructor
 */
export function AddOrderByParent(params, callback) {
    requestHandle(request({
        url: `${API_PREFIX}/parent/action/addOrder`,
        method: 'post',
        params
    }), callback)
}

/**
 * 家长待定订单列表
 * @constructor
 */
export function GetProducingOrders(params, callback) {
    return request({
        url: `${API_PREFIX}/parent/action/producingOrders`,
        method: 'get',
        params
    })
}

/**
 * 查找可以编辑的订单
 * @constructor
 */
export function GetPreOrder(params, callback) {
    requestHandle(request({
        url: `${API_PREFIX}/parent/action/getPreOrder`,
        method: 'get',
        params
    }), callback)
}

/**
 * 待定订单
 * @param params
 * @returns {AxiosPromise}
 * @constructor
 */
export function ProducingOrders(params) {
    return request({
        url: `${API_PREFIX}/parent/action/producingOrders`,
        method: 'get',
        params
    })
}


/**
 * 家长查看订单详情
 * @param params
 * @returns {AxiosPromise}
 * @constructor
 */
export function ParentOrderDetails(params, call) {
    requestHandle( request({
        url: `${API_PREFIX}/parent/action/orderDetails`,
        method: 'get',
        params
    }), call);
}

/**
 * 更新订单
 * @param params
 * @returns {*}
 * @constructor
 */
export function UpdateOrder(params) {
    return request({
        url: `${API_PREFIX}/parent/action/updateOrder`,
        method: 'post',
        data: params
    })
}

/**
 * 提交订单
 * @param params
 * @returns {AxiosPromise}
 * @constructor
 */
export function CommitOrder(params, callback) {
    requestHandle(request({
        url: `${API_PREFIX}/parent/action/commitOrder`,
        method: 'post',
        params
    }), callback);
}

/**
 * 删除订单
 * @param params ｛order_id：订单id, reason: 原因｝
 * @returns {AxiosPromise}
 * @constructor
 */
export function Delete(params) {
    return request({
        url: `${API_PREFIX}/parent/action/deleteOrder`,
        method: 'post',
        params
    });
}

/**
 * 撤回订单
 * @param params ｛order_id：订单id}
 * @returns {AxiosPromise}
 * @constructor
 */
export function CancelOrder(params, callback) {
    requestHandle(request({
        url: `${API_PREFIX}/parent/action/cancelOrder`,
        method: 'post',
        params
    }), callback);
}

/**
 * 查看报名者的简历
 * @param params ｛order_id：订单id}
 * @returns {AxiosPromise}
 * @constructor
 */
export function ViewResume(params, callback) {
    requestHandle(request({
        url: `${API_PREFIX}/parent/action/viewResume`,
        method: 'get',
        params
    }), callback);
}

/**
 * 查看报名者的简历
 * @param params ｛order_id：订单id}
 * @returns {AxiosPromise}
 * @constructor
 */
export function ChooseApply(params, callback) {
    requestHandle(request({
        url: `${API_PREFIX}/parent/action/chooseApply`,
        method: 'post',
        params
    }), callback);
}



/**
 * 取消选中报名者
 * @param params ｛order_id：订单id}
 * @returns {AxiosPromise}
 * @constructor
 */
export function CancelChooseApply(params, callback) {
    requestHandle(request({
        url: `${API_PREFIX}/parent/action/cancelChooseApply`,
        method: 'post',
        params
    }), callback);
}


/**
 * 家长取消交易，线下交流未果
 * @param params
 * @param callback
 * @constructor
 */
export function NO_DEAL(params, callback) {
    requestHandle(request({
        url: `${API_PREFIX}/parent/action/noDeal`,
        method: 'post',
        params
    }), callback);
}

/**
 * 家长查看历史订单
 * @param params
 * @param call
 * @constructor
 */
export function getHistoryOrdersOfParent(params, call) {
    requestHandle(request({
        url: `${API_PREFIX}/parent/action/historyOrders`,
        method: 'get',
        params
    }), call);
}

/**
 * 家长评价已经完成的订单
 * @param params
 * @param call
 */
export function evaluateOrder(params, call) {
    requestHandle(request(
        {
            url: `${API_PREFIX}/parent/action/evaluate`,
            method: "post",
            params
        }
    ), call);
}

/**
 * 停止服务
 * @param params
 * @param call
 */
export function finishOrder(params, call) {
    requestHandle(request(
        {
            url: `${API_PREFIX}/parent/action/finishOrder`,
            method: "post",
            params
        }
    ), call);
}

/**
 * 获取正在教学的订单
 * @param params
 * @param call
 */
export function getTeachingOrdersOfParent(params, call) {
    requestHandle(request(
        {
            url: `${API_PREFIX}/parent/action/workingOrders`,
            method: "get",
            params
        }
    ), call);
}